import React, {Component} from 'react';
import './index.less';
import {base} from 'nc-lightapp-front';
import EmptyImg from "../../../../../hrpub/common/components/emptyImg";
import handlePK from "../../container/functions/handlePK";
import setButtonStatus from "../../container/functions/setButtonStatus";

class MainTable extends Component {

    constructor(props) {
        super(props);
        this.state = {
            
        };
        this.checkDetail = this.checkDetail.bind(this);
        this.setTableHeight = this.setTableHeight.bind(this);
    }
    componentDidMount() {
        this.setTableHeight();
    }

    setTableHeight() {
        let wH = window.innerHeight,
			gap = 92;
		return wH - gap;
    }

    checkDetail(record, index, props, e) {
        handlePK.add(record.values.pk_workdispute.value)
        this.props.updateState({
            page: 'detail'
        }, () => {
            setButtonStatus.call(this, 'afterSave');
            this.props.initCardForm();
        });

    }

    afterEventHandle() {
        console.log('after')
    }

    render() {
        const {editTable,json,orgVal} = this.props;

        return (
            <div className='main-table'>
                {!orgVal.refpk ? <EmptyImg text={json['cm6011-000035']} /> /* 国际化处理： 暂无数据，请先选择人力资源组织*/ :
                    editTable.createEditTable('disputedlist', {
                        showCheck: false,
                        showIndex: true,
                        height: this.setTableHeight(),
                        // adaptionHeight: true,
                        onRowDoubleClick: this.checkDetail,
                        onAfterEvent: this.afterEventHandle
                })}
            </div>
        );
    }
}

export default MainTable;
